<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RegisterFormclass
 *
 * @author destiya
 */
class RegisterForm extends sfGuardUserForm {

    public function configure() {
        unset($this['algorithm'], $this['salt'], $this['is_active'],
                $this['is_super_admin'], $this['last_login'], $this['app_user_id'],
                $this['created_at'], $this['updated_at'], $this['groups_list'], $this['permissions_list']);

        $this->setWidgets(array(
            'username' => new sfWidgetFormInputText(),
            'password' => new sfWidgetFormInputPassword(),
            'confpass' => new sfWidgetFormInputPassword()
        ));

        $this->validatorSchema['username'] = new sfValidatorAnd(array(
            $this->validatorSchema['username'], new sfValidatorString(
                array('trim' => true, 'min_length'=>4
            ), array('min_length'=>'Username minimal 4 karakter'))
        ), array(), array('required'=>'Username harus diisi'));
        
        $this->validatorSchema['confpass'] = new sfValidatorAnd(array(
            $this->validatorSchema['password']
        ), array(), array('required'=>'Konfirmasi Password harus diisi'));

        $this->validatorSchema['password'] =  new sfValidatorAnd(array(
            $this->validatorSchema['password'], new sfValidatorString(array(
                'trim'=>true, 'min_length'=>5
            ),array('min_length'=>'Password minimal 5 karakter'))
        ),array(), array('required'=>'Password harus diisi'));

        
        $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('confpass', '==', 'password', array(),
                array('invalid'=>'Konfirmasi Password harus sama dengan Password')));

        $this->widgetSchema->setLabels(array(
            'confpass' => 'Konfirmasi Password'
        ));

        $this->widgetSchema['username']->setAttributes(array(
            'size' => 40, 'maxlength' => 100
        ));

        $this->widgetSchema['password']->setAttributes(array(
           'size' => 40, 'maxlength' => 100
        ));

        $this->widgetSchema['confpass']->setAttributes(array(
            'size' => 40, 'maxlength' => 100
        ));
        
     }

}
?>
